package game.games.hexagon;

import game.AbstractGame;

import java.awt.Graphics;
import java.awt.Polygon;

public class Hexagon extends AbstractGame
{
    private static Hexagon instance;
    
    public synchronized static Hexagon getInstance()
    {
        if (instance == null)
        {
            synchronized (Hexagon.class)
            {
                instance = new Hexagon();
            }
        }
        return instance;
    }

    public Hexagon()
    {
        super(false);
    }
    
    @Override
    public void render(Graphics g)
    {
        int corners = 8;
        int x = 25;
        int width = 15;
        Polygon p = new Polygon();
        for (int i = 0; i < corners; i++)
        {
            p.addPoint((int) (x + width * Math.cos(i * 2 * Math.PI / corners)), (int) (x + width * Math.sin(i * 2 * Math.PI / corners)));
        }
        g.drawPolygon(p);
        
        Polygon s = new Polygon();
        for (int i = 0; i < 360; i++)
        {
            double t = i / 360.0;
            s.addPoint((int) (150 + 50 * t * Math.cos(8 * t * Math.PI)), (int) (150 + 50 * t * Math.sin(8 * t * Math.PI)));
        }
        g.drawPolygon(s);
    }

    @Override
    protected void doNext()
    {
    }
    
    public static void main(String[] args)
    {
        Thread t = new Thread(Hexagon.getInstance(), "Hexagon");
        t.start();
    }
}
